#!/bin/sh
# PCP QA Test No. 741
# Exercise python script automated sys.argv context creation
#
# Copyright (c) 2014 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.python

status=1	# failure is the default!
$sudo rm -rf $tmp.* $seq.full
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15

$python -c "from pcp import pmapi" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmapi module not installed"

eval HOST=`pmprobe -v pmcd.hostname | awk '{ print $3 }'`

_filter_live()
{
    sed \
	-e '/^Align: /d' \
	-e '/^Start: /d' \
	-e '/^Finish: /d' \
	-e '/^Origin: /d' \
	-e "s/hostname: $HOST/hostname: HOST/g" \
	#
}

# real QA test starts here
echo && echo check archive and boundaries
$python $here/src/test_pcp_getopts.py -a archives/ace_v2 -z

echo && echo check archive time windows
$python $here/src/test_pcp_getopts.py -a archives/ace_v2 -z \
	--align="1 second" \
	--start="@ Mon Oct 30 14:25:10 1995" \
	--origin="@ Mon Oct 30 14:25:10 1995" \
	--finish="@ Mon Oct 30 14:25:15 1995"

echo && echo check multiple host contexts
$python $here/src/test_pcp_getopts.py -h local: -h local: | _filter_live

# success, all done
status=0
exit
